import { userListApi } from "@/api/users.js";
export default {
  state: {
    userList: {},
  },
  mutations: {
    changeUserList(state, data) {
      state.userList = data;
    },
  },
  actions: {
    async actChangeUserList(context, params) {
      let result = await userListApi(params);
      if (result) {
        result.data.map((val) => {
          let level = null;
          switch (val.level) {
            case "0":
              level = "管理员";
              break;
            case "1":
              level = "学生";
              break;
            case "2":
              level = "班主任";
              break;
          }
          val.level = level;
          return val;
        });
        context.commit("changeUserList", result);
      }
    },
  },
  getters: {},
};
